/**
 * Created by hui on 2016/9/27.
 */
$(function(){
    function onSuccess(data, status)
    {
        if (data.code === 0){
            $.mobile.loading('hide');
            setTimeout(function () {
                $("#popupView").popup('open');
            }, 100);
            $('#tips').html(data.msg);
        }else if(data.code === 1){
            location.href = '/center';
        }
    }

    function onError(data, status)
    {
        $.mobile.loading('hide');
        // handle an error
    }
    $("#group").click(function(){
        $.mobile.loading('show', {
            text: '登录中...', //加载器中显示的文字
            textVisible: true, //是否显示文字
            theme: 'b',        //加载器主题样式a-e
            textonly: false,   //是否只显示文字
            html: ""           //要显示的html内容，如图片等
        });
        var formData = $("#callAjaxForm").serialize();
        $.ajax({
            type: "POST",
            url: "login",
            cache: false,
            data: formData,
            success: onSuccess,
            error: onError
        });

        return false;

    });

});

$(function(){
    function onSuccess(data, status)
    {
        /*setTimeout(function () {
            $("#popupView").popup('open');
        }, 100);
        $('#tips').html(data.msg);
        if(data.code === 1){
            $('#submit').attr('href','/center');
            $('#submit').attr('data-rel','');
        }*/
        if (data.code === 0){
            $.mobile.loading('hide');
            setTimeout(function () {
                $("#popupView").popup('open');
            }, 100);
            $('#tips').html(data.msg);
        }else if(data.code === 1){
            $('#submit').attr('href','/center');
            $('#submit').attr('data-rel','');
        }
    }

    function onError(data, status)
    {
        $.mobile.loading('hide');
        // handle an error
    }
    $("#edit").click(function(){
        $.mobile.loading('show', {
            text: '修改中...', //加载器中显示的文字
            textVisible: true, //是否显示文字
            theme: 'b',        //加载器主题样式a-e
            textonly: false,   //是否只显示文字
            html: ""           //要显示的html内容，如图片等
        });
        var formData = $("#callAjaxForm").serialize();
        $.ajax({
            type: "POST",
            url: "changepwd",
            cache: false,
            data: formData,
            success: onSuccess,
            error: onError
        });

        return false;

    });

});